package dbschema

import (
	"git.sr.ht/~mil/mobsql/sqlgen"
)

var tablesComputed = []sqlgen.ComputedTable{
	{
		Doc:           `Computed table for the _cvconnd view`,
		View:          `_vconnd`,
		CacheOnTables: []string{"stop_times", "trips", "stops", "routes"},
		TableSpec: sqlgen.TableSpec{
			Table:     "_cvconnd",
			Indexes:   [][]string{{"source", "service_id", "from_stop_time"}},
			UniqueSet: []string{"source", "conn_id"},
			Columns: []sqlgen.LoadColumn{
				{Column: "source", DType: sqlgen.DTypeInt, Required: true},
				{Column: "conn_id", DType: sqlgen.DTypeText, Required: true},
				{Column: "trip_id", DType: sqlgen.DTypeText, Required: true},
				{Column: "service_id", DType: sqlgen.DTypeText, Required: true},
				{Column: "from_stop_id", DType: sqlgen.DTypeText, Required: true},
				{Column: "from_stop_idu", DType: sqlgen.DTypeText, Required: true},
				{Column: "from_stop_sidu", DType: sqlgen.DTypeText, Required: true},
				{Column: "from_stop_time", DType: sqlgen.DTypeInt, Required: true},
				{Column: "from_stop_sequence", DType: sqlgen.DTypeInt, Required: true},
				{Column: "to_stop_id", DType: sqlgen.DTypeText, Required: true},
				{Column: "to_stop_idu", DType: sqlgen.DTypeText, Required: true},
				{Column: "to_stop_sidu", DType: sqlgen.DTypeText, Required: true},
				{Column: "to_stop_time", DType: sqlgen.DTypeInt, Required: true},
				{Column: "to_stop_sequence", DType: sqlgen.DTypeInt, Required: true},
			},
		},
	},
	{
		View:          "_vstopparent",
		SourcePair:    false,
		CacheOnTables: []string{"stops"},
		TableSpec: sqlgen.TableSpec{
			Table: "_cvstopparent",
			Columns: []sqlgen.LoadColumn{
				{Column: "source", DType: sqlgen.DTypeInt, Required: true},
				{Column: "stop_id", DType: sqlgen.DTypeText, Required: true},
				{Column: "parent_station", DType: sqlgen.DTypeText, Required: true},
			},
		},
	},
	{
		View:          "_vtransfersgen",
		SourcePair:    false,
		CacheOnTables: []string{"stops"},
		TableSpec: sqlgen.TableSpec{
			Table: "_cvtransfersgen",
			Columns: []sqlgen.LoadColumn{
				{Column: "transfer_category", DType: sqlgen.DTypeText, Required: true},
				{Column: "source", DType: sqlgen.DTypeInt, Required: true},
				{Column: "source_pair", DType: sqlgen.DTypeInt, Required: true},
				{Column: "from_stop_id", DType: sqlgen.DTypeText, Required: true},
				{Column: "to_stop_id", DType: sqlgen.DTypeText, Required: true},
				{Column: "from_stop_idu", DType: sqlgen.DTypeText, Required: true},
				{Column: "to_stop_idu", DType: sqlgen.DTypeText, Required: true},
				{Column: "from_stop_sidu", DType: sqlgen.DTypeText, Required: true},
				{Column: "to_stop_sidu", DType: sqlgen.DTypeText, Required: true},
				{Column: "transfer_type", DType: sqlgen.DTypeInt},
				{Column: "min_transfer_time", DType: sqlgen.DTypeInt},
				{Column: "dist_km", DType: sqlgen.DTypeReal},
			},
		},
	},
}
